package com.jiyinit.web.core.business.dao;

import com.jiyinit.core.framework.dao.mybatis.base.MybatisDaoContext;
import com.jiyinit.web.core.business.entity.TabCoreUserRoleEntity;
import com.jiyinit.web.core.business.vo.UserRoleVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

/**
 * 用户与角色关系dao
 * @author zhaolaiwei
 * @version 1.0
 * @date 2017/4/20 10:52
 * @since 1.0
 */
@Repository("core.tabCoreUserRoleDao")
public class TabCoreUserRoleDao {

    /**
     * 日志对象
     */
    private static Logger logger = LoggerFactory.getLogger(TabCoreUserRoleDao.class);

    private String SQLID = "core.tabCoreUserRoleDao.";

    @Autowired
    @Qualifier("core.MybatisDaoContext")
    private MybatisDaoContext mybatisDaoContext;

    public int insert(TabCoreUserRoleEntity tabCoreUserRole) {
        return mybatisDaoContext.save(SQLID + "insert", tabCoreUserRole);
    }

    public int updateByUserId(TabCoreUserRoleEntity tabCoreUserRole) {
        return mybatisDaoContext.update(SQLID + "updateByUserId", tabCoreUserRole);
    }

    public TabCoreUserRoleEntity selectByUserId(Integer userId) {
        return mybatisDaoContext.findOne(SQLID + "selectByUserId", TabCoreUserRoleEntity.class, userId);
    }

    public int deleteByUserId(TabCoreUserRoleEntity tabCoreUserRole) {
        return mybatisDaoContext.delete(SQLID + "deleteByUserId", tabCoreUserRole);
    }

    public UserRoleVo selectUserRoleVoByUserId(Integer userId){
        return mybatisDaoContext.findOne(SQLID + "selectUserRoleVoByUserId", UserRoleVo.class, userId);
    }


}
